<?php
header("Content-type: text/html; charset=utf-8");
session_start();
include 'mysql.php';
if(strtolower($_SERVER['REQUEST_METHOD']) == 'post')
{
    $param = $_POST['Form'];
    $name = $param['name'];
    $password = $param['password'];
    $query = "INSERT INTO  `user` (`id`,`name`,`password`) VALUES (NULL, '".$name."','".$password."')";
    $result=$mysqli->query($query);
    if($result)
    {
        $_SESSION["name"] = $name ;
        header("Location:/");
    }
    else
    {
        echo  "<script>alert('注册失败');window.location.href='/'</script>";
    }



}



$month_array = array('01'=>'Jan','02'=>'Feb','03'=>'Mar','04'=>'Apr','05'=>'May','06'=>'Jun','07'=>'Jul','08'=>'Aug','09'=>'Sep','10'=>'Oct','11'=>'Nov','12'=>'Dec');
$year = date('Y',time());
$month  = $month_array[date('m',time())];
$day = date('d',time());

?>

<!DOCTYPE html>
<html>
	<head>
		<!-- Title here -->
		<title>Your Title</title>
		<!-- Description, Keywords and Author -->
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta name="description" content="Your description">
		<meta name="keywords" content="Your,Keywords">
		<meta name="author" content="ResponsiveWebInc">
		
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,600,700' rel='stylesheet' type='text/css'>
		<link href='http://fonts.googleapis.com/css?family=Lobster+Two:700' rel='stylesheet' type='text/css'>
		<link href='http://fonts.googleapis.com/css?family=Droid+Serif:400,400italic' rel='stylesheet' type='text/css'>
		
		<!-- Styles -->
		<!-- Bootstrap CSS -->
		<link href="css/bootstrap.min.css" rel="stylesheet">
		<!-- FlexSlider -->
		<link href="css/flexslider.css" rel="stylesheet">
		<!-- Font awesome CSS -->
		<link href="css/font-awesome.min.css" rel="stylesheet">		
		<!-- Custom CSS -->
		<link href="css/style.css" rel="stylesheet">
		
		<!-- Favicon -->
		<link rel="shortcut icon" href="#">
        <!-- Javascript files -->
		<!-- jQuery -->
		<script src="js/jquery.js"></script>
		<!-- Bootstrap JS -->
		<script src="js/bootstrap.min.js"></script>
		<!-- FlexSlider -->
		<script src="js/jquery.flexslider-min.js"></script>
		<!-- jQuery Anchor Plugin -->
		<script src="js/jquery.anchor.js"></script>
		<!-- Respond JS for IE8 -->
		<script src="js/respond.min.js"></script>
		<!-- HTML5 Support for IE -->
		<script src="js/html5shiv.js"></script>
		<!-- Custom JS -->
		<script src="js/custom.js"></script>
        <script type="text/javascript">

            $(function(){


                $('form[name="form_submit"]').submit(function(){

                    var name = $('#name').val();
                    var password = $('#password').val();
                    var repassword = $('#repassword').val();

                    if(!name.length){
                        $('#name').focus();
                        return false ;
                    }

                    if(!password.length){
                        $('#password').focus();
                        return false ;
                    }else{

                        if(password.length<7)
                        {
                            alert('密码长度必须6位以上');
                        }

                    }

                    if(!repassword.length){
                        $('#repassword').focus();
                        return false ;
                    }
                    else
                    {
                        if(repassword!==password)
                        {
                            alert('两次密码不一致');
                            return false ;
                        }
                    }


                });
            })

        </script>
	</head>
	
	<body>
	<!-- Navigation Starts -->
		<div class="navbar navbar-default navbar-fixed-top bs-docs-nav" role="banner">
			<div class="container">
				<div class="navbar-header">
					<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".bs-navbar-collapse">
					  <span class="sr-only">Toggle navigation</span>
					  <span class="icon-bar"></span>
					  <span class="icon-bar"></span>
					  <span class="icon-bar"></span>
					</button>
					<a class="navbar-brand" href="#">Find &amp; The Passion</a>
				</div>

				<nav class="collapse navbar-collapse bs-navbar-collapse" role="navigation">
					<ul class="nav navbar-nav navbar-right">
						<li><a href="/">主页</a></li>
						<li><a href="/" class="anchorLink">关于我们</a></li>
						<li><a href="/" class="anchorLink">照片</a></li>
						<li><a href="/" class="anchorLink">活动</a></li>
						<li><a href="/" class="anchorLink">房屋沟</a></li>
                        <li><a href="admin.php" target="_blank">活动管理</a></li>
					</ul>
				</nav>


			</div>
		</div>
		<a name="home" id="home"></a>
		<!-- Navigation Ends -->

		<!-- Main Starts -->
		<div class="main">
			<div class="container">
				<div class="row">
					<div class="col-md-8 col-sm-7">
						<div class="main-invite">
							<div class="signal"><i class="icon-signal"></i>	 <span>一起来</span></div>
							<h1>我们<br>
								都在享受生活</h1>
							<p>享受生活，需要一种心境。平静地坐看时光流逝，平静地细数人世坎坷，这些都是享受生活的意境。生活的意义，不在权势和金钱，不在物质和名利，而在用一颗平淡无华的心情，去领悟生活中风雨兼程与风和日丽。</p>
						</div>
					</div>
					<div class="col-md-4 col-sm-5">
						<div class="main-date">
							<i class="icon-heart"></i>
							<div class="date"><span class="month"><strong><?php echo $day ;?>,<?php echo $month;?></strong></span><br><span class="year"><strong><?php echo $year;?></strong></span></div>
						</div>
					</div>
				</div>
				<a name="about" id="about"></a>
			</div>
		</div>
		<!-- Main Ends -->
		



		
		<!-- RSVP Starts -->
		<div class="rsvp">
			<div class="container">
				<div class="title">
							<h3>快来注册吧</h3>
				</div>
				<div class="bor"></div>
				
				<div class="row">
					<div class="col-md-3 col-sm-3">
						<div class="heart">
							<i class="icon-heart"></i>
						</div>
					</div>
					<div class="col-md-6 col-sm-6">
						<div class="well">
							<p>在这里我们真诚交友，在这里我们共享生活，快来加入吧！我们一起共创美好幸福的生活。</p>
							<form class="form-horizontal" role="form"  name="form_submit" action="" method="post">
							    <div class="form-group">
									<label class="control-form col-md-3" for="name">姓名</label>
									<div class="col-md-9">
										<input type="text" class="form-control" name="Form[name]" id="name" placeholder="请输入用户名">
									</div>
								</div>
								<div class="form-group">
									<label class="control-form col-md-3" for="attentive">密码</label>
									<div class="col-md-9">
										<input type="password" class="form-control" name="Form[password]" maxlength="20" id="password" placeholder="请输入密码">
									</div>
								</div>
                                <div class="form-group">
									<label class="control-form col-md-3" for="attentive">重复密码</label>
									<div class="col-md-9">
										<input type="password" class="form-control" maxlength="20" id="repassword" placeholder="请输入确认密码">
									</div>
								</div>
								<div class="form-group">
									<div class="col-md-9 col-md-offset-3">
									<input type="submit" class="btn btn-danger" value="Submit">
									</div>
								</div>
							</form>
						</div>
					</div>
					<div class="col-md-3 col-sm-3">
						<div class="heart">
							<i class="icon-heart"></i>
						</div>
					</div>
				</div>
				<hr>
			</div>
		</div>
		
		<!-- RSVP Ends -->
		
		<!--Footer Starts -->
		<!--Footer Ends -->
		<span class="totop"><a href="#"><i class="icon-chevron-up"></i></a></span>
	</body>	
</html>